#!/bin/bash
APP=edu

if [ -n "$2" ] ;then
   do_date=$2
else
   echo "请传入日期参数"
   exit
fi

# 这是sql语句
dim_user_zip="
insert overwrite table dim_user_zip partition (dt = '9999-12-31')
select
    data.id,
    data.login_name		,
    data.nick_name		,
    data.passwd			,
    data.real_name		,
    data.phone_num		,
    data.email			,
    data.head_img		,
    data.user_level		,
    data.birthday		,
    data.gender			,
    data.create_time	,
    date_format(nvl(data.operate_time,data.create_time),'yyyy-MM-dd')	start_time,
    "9999-12-31" end_time
from ods_user_info_inc where dt = '{do_date}'
and type='bootstrap-insert';
"


case $1 in
    "dim_user_zip" )
        /opt/module/hive/bin/hive -e "use ${APP};dim_user_zip"
    ;;



    "all" )
        /opt/module/hive/bin/hive -e "
        use ${APP};
        $dim_user_zip

        "
    ;;
esac